package com.whimscrew.user.controller;

import com.whimscrew.user.model.User;
import com.whimscrew.user.model.Video;
import com.whimscrew.user.service.VideoService;
import org.apache.commons.lang.RandomStringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("v1/user")
public class UserController {


    @Autowired
    VideoService videoService;


    @GetMapping("/{userId}")
    public User getUser(@PathVariable Long userId )   {
        String name =  RandomStringUtils.random(3  , 0x4e00, 0x9fa5, false, false);
        return new User(name, userId);
    }

    @GetMapping("video-uploads/{userId}")
    public List<Video> uploads(@PathVariable Long userId )   {
        return  videoService.uploadList(userId);
    }


}
